package com.talkweb.osmharmony.views.drawing;


import com.talkweb.osmharmony.util.PointL;
import com.talkweb.osmharmony.views.Projection;
import ohos.agp.render.PixelMapHolder;
import ohos.agp.render.PixelMapShader;
import ohos.agp.utils.Matrix;
import ohos.media.image.PixelMap;

@Deprecated
public class OsmBitmapShader extends PixelMapShader {
    private static final PointL sPoint = new PointL();

    private final Matrix mMatrix = new Matrix();
    private int mBitmapWidth;
    private int mBitmapHeight;

    public OsmBitmapShader(PixelMap bitmap, TileMode tileX, TileMode tileY) {
        super(new PixelMapHolder(bitmap), tileX, tileY);
        mBitmapWidth = bitmap.getImageInfo().size.width;
        mBitmapHeight = bitmap.getImageInfo().size.height;
    }

    public void onDrawCycle(Projection projection) {
        projection.toMercatorPixels(0, 0, sPoint);
        mMatrix.setTranslate(-sPoint.x % mBitmapWidth, -sPoint.y % mBitmapHeight);
        setShaderMatrix(mMatrix);
//        setLocalMatrix(mMatrix);
    }
}
